var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [{
			colkey : "file_number",
			name : "档案号"
		},{
			colkey : "job_number",
			name : "工号"
		},{
			colkey : "name",
			name : "姓名",
			
		},{
			colkey : "dname",
			name : "部门",
			
		},{
			colkey : "position_name",
			name : "职务",
			
		},{
			colkey : "nation",
			name : "民族",
			
		},{
			colkey : "address",
			name : "住址",
			
		}, {
			colkey : "IdCard",
			name : "身份证号",
			
		},{
			colkey : "sex",
			name : "性别",
			renderData : function(rowindex,data, rowdata, column) {
				if(data==1){ return "男"}else{return "女"};
			}
		},{
			colkey : "marital_status",
			name : "婚否",
			renderData : function(rowindex,data, rowdata, column) {
				if(data==0){ return "已婚"}else{return "未婚"};
			}
		},{
			colkey : "education",
			name : "学历",
			
		},{
			colkey : "factory_date",
			name : "离厂日期",
			renderData : function(rowindex,data, rowdata, column) {
					return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{	
			colkey : "first_entry",
			name : "入厂日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "contract_date",
			name : "签订合同时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "contract_expiration",
			name : "合同到期时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "phone",
			name : "联系电话",
			
		},{
			colkey : "emergency_telephone",
			name : "紧急联系电话",
			
		},{
			colkey : "renewal_date",
			name : "续签时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "rehelloring_date",
			name : "返聘时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "social_security",
			name : "社保",
			renderData : function(rowindex,data, rowdata, column) {
				if(data+1){ return "已购买"}else{return "没购买"};
			}
		},{
			colkey : "business_insurance",
			name : "商保",
			renderData : function(rowindex,data, rowdata, column) {
				if(data==1){ return "是"}else{return "否"};
			}
		},{
			colkey : "state",
			name : "状态",
			renderData : function(rowindex,data, rowdata, column) {
				if(data==1){ return "在职"}else{return "离职"};
			}
		}],
		jsonUrl : rootPath + '/hrrecord/record_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
});
	$("#addOrder").click("click", function() {
		addAccount();
	});
	$("#editOrder").click("click", function() {
		editAccount();
	});
	$("#delOrder").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});

	





function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "编辑档案信息",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/hrrecord/record_edit.shtml?id=' + cbox
	});
}


